/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package digitaldreamers.games.ddmonsters.servers.gameserver.components;

import java.util.ArrayList;

/**
 *
 * @author DaoLe
 */
public class PlayerDuelStatusComponent {
    
    // <editor-fold defaultstate="collapsed" desc="Constants">
    
    // <editor-fold defaultstate="collapsed" desc="Error messages">
    private static final String CARD_IS_NULL_ERROR_MESSAGE = "Card can not be null.";
    // </editor-fold>
    
    public static final int NUMBER_OF_CARDS_DRAWN_AT_START = 5;
    public static final int MAX_NUMBER_OF_CARDS_IN_HAND = 5;
    public static final int INITIAL_LP = 4000;
    public static final int INITIAL_MP = 2000;
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Member variables">
    private int m_iLP;
    private int m_iMP;
    private PlayerComponent m_Player;
    private DeckComponent m_DuelDeck;
    private ArrayList<PlayerCardComponent> m_CardsInHand;
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Get/Set methods">
    
    // <editor-fold defaultstate="collapsed" desc="LP">
    public int getLP() {
        return m_iLP;
    }
    
    public void setLP(int iLP) {
        m_iLP = iLP;
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="MP">
    public int getMP() {
        return m_iMP;
    }
    
    public void setMP(int iMP) {
        m_iMP = iMP;
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Player">
    public PlayerComponent getPlayer() {
        return m_Player;
    }
    
    public void setPlayer(PlayerComponent player) {
        m_Player = player;
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Duel deck">
    public DeckComponent getDuelDeck() {
        return m_DuelDeck;
    }
    
    public void setDuelDeck(DeckComponent duelDeck) {
        m_DuelDeck = duelDeck;
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Number of cards in hand">
    public int getNumberOfCardsInHand() {
        return m_CardsInHand.size();
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Card in hand at index">
    public PlayerCardComponent getCardInHandAtIndex(int iIndex) {
        if(iIndex < 0 || iIndex >= m_CardsInHand.size()) {
            return null;
        }
        return m_CardsInHand.get(iIndex);
    }
    // </editor-fold>
    
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Constructors">
    
    // <editor-fold defaultstate="collapsed" desc="PlayerDuelStatusComponent()">
    public PlayerDuelStatusComponent(PlayerComponent player) {
        m_iLP = INITIAL_LP;
        m_iMP = INITIAL_MP;
        m_Player = player;
        m_DuelDeck = player.getActiveDeck();
        m_CardsInHand = new ArrayList<>(MAX_NUMBER_OF_CARDS_IN_HAND);
    }
    // </editor-fold>
    
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Methods">
    
    // <editor-fold defaultstate="collapsed" desc="addCardToHand(PlayerCardComponent card)">
    public boolean addCardToHand(PlayerCardComponent card) throws IllegalArgumentException {
        if(card == null) {
            throw new IllegalArgumentException(CARD_IS_NULL_ERROR_MESSAGE);
        }
        if(!m_CardsInHand.contains(card)) {
            return m_CardsInHand.add(card);
        }
        return false;
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="removeCardFromHandByIndex(int iIndex)">
    public PlayerCardComponent removeCardFromHandByIndex(int iIndex) {
        if(iIndex < 0 || iIndex >= m_CardsInHand.size()) {
            return null;
        }
        return m_CardsInHand.remove(iIndex);
    }
    // </editor-fold>
    
    // </editor-fold>
}
